package org.xdq.互斥;

public class Test {




    public static void main(String[] args) {

        Object lock = new Object();

        new Thread(()->{
            String str = "大家好！今天是周五，明天可以休息了！";
            synchronized (lock){
                for (int i = 0; i < str.length(); i++) {
                    System.out.print(str.charAt(i));
                }
                System.out.println();
                System.out.println("--------------------------------------------");
            }
        }).start();

        new Thread(()->{
            String str = "制度稳则国家稳，制度强则国家强。人民代表大会制度是我国根本政治制度。";
            synchronized (lock) {
                for(int i=0;i<str.length();i++){
                    System.out.print(str.charAt(i));
                }
                System.out.println();
                System.out.println("--------------------------------------------");
            }
        }).start();


    }


}
